package com.atguigu.utils;

import java.util.concurrent.CountDownLatch;

public class CountDownLatchDemo {
    public static void main(String[] args)throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(0);

        for (int i = 1; i <=6; i++) {
            new Thread(() -> {
                System.out.println(Thread.currentThread().getName()+"\t"+"===离开教室,结束学习");
                countDownLatch.countDown();
            },String.valueOf(i)).start();
        }


        countDownLatch.await();
        System.out.println(Thread.currentThread().getName()+"--------班长关灯锁门");
    }
}
